package cn.hfuu.service.impl;

import cn.hfuu.dao.SaleVisitDao;
import cn.hfuu.domain.SaleVisit;
import cn.hfuu.service.SaleVisitService;
import cn.hfuu.utils.PageBean;
import org.hibernate.criterion.DetachedCriteria;

import java.util.List;

public class SaleVisitServiceImpl implements SaleVisitService {

    private SaleVisitDao saleVisitDao;
    public void save(SaleVisit saleVisit) {
        //调用dao层方法保存销售信息表
        saleVisitDao.save(saleVisit);

    }
    @Override
    public void update(SaleVisit saleVisit) {
        saleVisitDao.update(saleVisit);
    }
    public PageBean getPageBean(DetachedCriteria dc, Integer currentPage, Integer pageSize) {

        //调用dao层方法查询总记录数
        Integer totalCount = saleVisitDao.getTotalCount(dc);
        //查询当前页面显示列表

        PageBean pb = new PageBean(totalCount,currentPage,pageSize);

        List<SaleVisit> list = saleVisitDao.getPageList(dc,pb.getStart(),pb.getPageSize());
        pb.setList(list);

        return pb;
    }

    @Override
    public SaleVisit getById(String visit_id) {

        return saleVisitDao.getById(visit_id);

    }



    public void setSaleVisitDao(SaleVisitDao saleVisitDao) {
        this.saleVisitDao = saleVisitDao;
    }
}
